package com.ruoyi.web.controller.shouhou;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.EpmInformation;
import com.ruoyi.system.domain.ShouhouRecord;
import com.ruoyi.system.service.IEpmShouhouRecordService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 售后完成信息表controller
 */


@RestController
@RequestMapping("/Empment/shouhou")
public class EpmShouhouRecordController extends BaseController {
    @Autowired
    private IEpmShouhouRecordService iEpmShouhouRecordService;

    /**
     * 查询售后记录表
     */
    @PreAuthorize("@ss.hasPermi('Empment:record:list')")
    @GetMapping("/record/list")
    public TableDataInfo list(ShouhouRecord shouhouRecord) {
        startPage();
        List<ShouhouRecord> list = iEpmShouhouRecordService.list(shouhouRecord);
        System.out.println(list);
        System.out.println(list);
        System.out.println(list);
        System.out.println(list);
        System.out.println(list);
        return getDataTable(list);
    }


    /**
     * 删除记录
     */
    @PreAuthorize("@ss.hasPermi('Empment:record:delete')")
    @DeleteMapping("/record/delete/{ids}")
    public AjaxResult delete(@PathVariable Integer[] ids) {
        iEpmShouhouRecordService.delete(ids);
        return AjaxResult.success();
    }


    /**
     * 导出记录
     */
    @PreAuthorize("@ss.hasPermi('Empment:record:export')")
    @Log(title = "售后记录", businessType = BusinessType.EXPORT)
    @PostMapping("/record/export")
    public void export(HttpServletResponse response, ShouhouRecord shouhouRecord) {
        List<ShouhouRecord> list = iEpmShouhouRecordService.list(shouhouRecord);
        ExcelUtil<ShouhouRecord> util = new ExcelUtil<ShouhouRecord>(ShouhouRecord.class);
        util.exportExcel(response, list, "售后记录数据");
    }
}
